<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    





    <script>

        // 存储数据
        let obj = {
            username:'wang',
            age:20,
            sex:'男'
        };
        let str = JSON.stringify(obj);
        localStorage.setItem('user',str);

        // 获取数据
        let res = localStorage.getItem('user');
        console.log(res);





    </script>
</body>
</html>